package com.suyuan.controller.admin;

import com.github.pagehelper.PageInfo;
import com.suyuan.entity.Permission;
import com.suyuan.service.PermissionService;
import com.suyuan.utils.JsonMessage;
import com.suyuan.web.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 *
 * 权限控制器
 * 此类暂时只提供列表方法
 */
@Controller
@RequestMapping(value = "/admin/permission")
public class PermissionController {

    @Resource(name = "permissionService")
    private PermissionService permissionService;

    /**
     * 列表
     * @return
     */
    @RequestMapping(value = "/list")
    public String list(Page page, ModelMap model){
        PageInfo info = permissionService.list(page);
        model.addAttribute("page",info);
        return "permission_list";
    }

    /**
     * 添加页面
     * 暂不提供添加权限的方法
     * @return
     */
    //@RequestMapping(value = "/add")
    public String add(){
        return "";
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(Integer id){
        return JsonMessage.success("");
    }

    /**
     * 保存
     * @param permission
     * @return
     */
    //@RequestMapping( value = "/save")
    public String save(Permission permission){
        return "redirect:/admin/permission/list";
    }
}
